#ifndef XBELTREE_H
#define XBELTREE_H

#include <QtGui>
#include <QDomDocument>
#include <QHash>
#include <QIcon>
#include <QTreeWidget>

class XbelTree : public QTreeWidget
{
    Q_OBJECT

public:
    XbelTree(QWidget *parent = 0);

    bool read(QIODevice *device);
    bool write(QFile *file);
    bool slot_new(QFile *file_new);
    void writeIndexEntry(QXmlStreamWriter *xmlWriter, QTreeWidgetItem *item);
    bool slot_insertItem(bool child);
    bool slot_deleteItem();
    bool slot_raschet();
    void ras_init(QTreeWidgetItem *item);
    void ras_func(QTreeWidgetItem *item);
    void slot_ras_number(QTreeWidgetItem *item);

private slots:
    void updateDomElement(QTreeWidgetItem *item, int column);

private:
    void parseFolderElement(const QDomElement &element,
                            QTreeWidgetItem *parentItem = 0);
    QTreeWidgetItem *createItem(const QDomElement &element,
                                QTreeWidgetItem *parentItem = 0);

    QDomDocument domDocument;
    QHash<QTreeWidgetItem *, QDomElement> domElementForItem;
    QIcon folderIcon;
    QIcon elementIcon;
};

#endif
